package com.shenglaotuan.community.common.service;

import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.stereotype.Service;

/**
 * 加密服务
 */
@Service
public class EncodeService {

    /**
     * MD5加密密码
     * @param password 密码
     * @param salt 盐值
     * @return 加密后的密码
     */
    public String getMD5Password(String password, String salt){
        String result = salt + password + salt;
        for (int i = 0; i < 3; i++) {
            result = DigestUtils.md5Hex(result);
        }
        return result;
    }
}
